package cn.edu.tsinghua.sthuapp;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.ViewGroup;
import android.view.animation.AlphaAnimation;
import android.view.animation.Animation;
import android.view.animation.Animation.AnimationListener;
import android.widget.ImageView;

public class OpenActivity extends Activity {
	private ImageView start;
	private ViewGroup topLayout;
	@Override
	public void onCreate(Bundle savedInstanceState){
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_open);
		start = (ImageView)this.findViewById(R.id.startImg);
		topLayout = (ViewGroup)this.findViewById(R.id.topLayout);
		AlphaAnimation animation = new AlphaAnimation(1.0f,0.0f);
		animation.setDuration(500);
		animation.setStartOffset(3000);
		animation.setAnimationListener(new AnimationListener(){

			@Override
			public void onAnimationEnd(Animation arg0) {
				// TODO Auto-generated method stub
				topLayout.removeView(start);
				Intent intent = new Intent(OpenActivity.this,EventListActivity.class);
				OpenActivity.this.finish();
				startActivity(intent);
			}

			@Override
			public void onAnimationRepeat(Animation arg0) {
				// TODO Auto-generated method stub
				
			}

			@Override
			public void onAnimationStart(Animation arg0) {
				// TODO Auto-generated method stub
				
			}
			
		});
		start.startAnimation(animation);
	}
	
	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.main, menu);
		return true;
	}
}
